package com.dd.ms.auth.repository;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dd.ms.auth.mapper.RoleMapper;
import com.dd.ms.auth.pojo.DO.RoleDO;
import com.dd.ms.auth.pojo.DO.UserDO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;

import javax.management.relation.Role;
import java.util.List;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/7/10 9:25
 * @Description 类功能作用说明
 */
@Repository
@RequiredArgsConstructor
public class RoleRepository {

    private final RoleMapper roleMapper;

    public List<RoleDO> selectList(List<Long> roleIds) {
        LambdaQueryWrapper<RoleDO> lqw = new LambdaQueryWrapper<>();
        lqw.in(CollUtil.isNotEmpty(roleIds), RoleDO::getRoleId, roleIds);
        return roleMapper.selectList(lqw);
    }

    public RoleDO selectOne(String roleName) {
        LambdaQueryWrapper<RoleDO> lqw = new LambdaQueryWrapper<>();
        lqw.eq(RoleDO::getRoleName, roleName);
        return roleMapper.selectOne(lqw);
    }
}
